<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Stimulus360.Controllers.Ideas.NewIdeaViewModel>" %>
<%@ Import Namespace="Stimulus360.Models.Data" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <%
        List<SelectListItem> items = new List<SelectListItem>();
        //SelectListItem item;
        if (Model.Categories != null)
            foreach (var category in Model.Categories)
            {
                //item = new SelectListItem { Text = category.Category, Value = category.CategoryId.ToString()};
                items.Add(new SelectListItem { Text = category.Category, Value = category.CategoryId.ToString() });
            }
        items.Insert(0, new SelectListItem { Text = "Select", Value = "" });
    %>
    <% using (Html.BeginForm())
       {%>
    <%=Html.AntiForgeryToken() %>
    <div class="mainInner fullViewHdr pt10">
        <h3>
            New Idea Submission</h3>
        <div class="errorMessages">
            <%= Html.ValidationSummary(Stimulus360.Resources.Stimulus360.ValidationSummary_MandatoryDetails )%></div>
        <div id="container">
            <ul>
                <li>
                    <label class="desc">Title</label>
                    <div>
                        <%=Html.TextBox("title", Model.Idea.Title, new { @tabindex="1", @size="70", @maxlength="80" })%>
                        <%= Html.ValidationMessage("Title", "*", new { @class = "requiredfield" })%>
                    </div>
                </li>
                <li>
                    <label class="desc">Category</label>
                    <div>
                        <%=Html.DropDownList("category", items.AsEnumerable(), new { @size = "1", @tabindex = "2" })%>
                        <%=Html.ValidationMessage("CategoryId", "*", new { @class = "requiredfield" })%>
                        <%=Html.Hidden("categoryId", Model.Idea.CategoryId) %>
                    </div>
                </li>
                <li>
                    <label class="desc">Description</label>
                    <div class="floatLeft"><%=Html.TextArea("description", Model.Idea.Description, new { @cols = "70", @rows = "10", @tabindex = "3" })%></div>
                        <div class="floatLeft">&nbsp;<%=Html.ValidationMessage("Description", "*", new { @class = "requiredfield" })%></div>
                    
                </li>
                <li class="buttons">
                    <input name="submit" type="submit" id="saveForm" value="Submit" tabindex="4" />&nbsp;&nbsp;
                    <input name="cancel" type="button" id="cancelForm" value="Cancel" tabindex="5" />
                </li>
            </ul>
        </div>
    </div>
    <br clear="all" />
    <% } %>

    <script language="javascript" type="text/javascript">
    $(document).ready(function() {
        $("#category").change(function() {
            $("#categoryId").val($("OPTION:selected", this).val());
        });

        $("#cancelForm").click(function() {
            window.location = "/Ideas";
        });
    });
    </script>

</asp:Content>
